<template>
  <div>

    <zh-form ref="formInfo"  :rules="rules" :model="formInfo"  labelAlign="right" >

      <zh-card style="width:100%;float:left">

        <zh-row :span="18">

          <zh-input prop="disposalManList"   type="select"
                    :defaultFields='{label:"fullName",value:"userId",}' :options="disposalManData" label="请选择处置人员(单选)"
                    v-model="formInfo.disposalManList"></zh-input>
        </zh-row>
        <zh-row :span="18">
        <zh-input prop="dutyLeaderList"   type="select"
                   :defaultFields='{label:"fullName",value:"userId",}' :options="disposalManData" label="请选择责任领导(单选)"
                  v-model="formInfo.dutyLeaderList"></zh-input>
        </zh-row>
        <zh-row :span="18">
          <zh-input prop="departmentLeaderList"   type="select"
                    :defaultFields='{label:"fullName",value:"userId",}' :options="disposalManData" label="请选择科室领导(单选)"
                    v-model="formInfo.departmentLeaderList"></zh-input>
        </zh-row>
        <div style="height: 50px">

        </div>
      </zh-card>
    </zh-form>
  </div>
</template>

<script>
import moment from 'moment'
import modal from "ant-design-vue/lib/modal";
import {getDisposalManData,disposalAllotTaskBatch
} from '@/services/system/whdngxlApi'
export default {
  components:{

  },
  props:{
    listQuery:{
      type:Function,
      default:null
    },
  },
  data() {
    return {
      formInfo:{
        disposalManList:'',
        dutyLeaderList:'',
        departmentLeaderList:'',
      },
      rules: {
      },
      disposalManData: [],
    }
  },

  created() {},
  methods: {
    moment,
    initData(manageAreas){
      //获取处置人员列表
      const params = {}
      params.manageAreas = manageAreas
      setTimeout(() => {
        this.$http.post(getDisposalManData, params).then((res) => {
          if(res.result){
            this.disposalManData = res.result
          }
        }).catch((error) => {
          console.log(JSON.stringify(error))
        }).finally(() =>{
        })
      }, 50)
    },
    allotTaskBatch(disposalPsAllotVOS){
      if(this.formInfo.disposalManList == null || this.formInfo.disposalManList == '') {
        modal.warn({title: '温馨提示', content: '处置人员不能为空'})
        return
      }
      if(this.formInfo.dutyLeaderList == null || this.formInfo.dutyLeaderList == '') {
        modal.warn({title: '温馨提示', content: '责任领导不能为空'})
        return
      }
      if(this.formInfo.departmentLeaderList == null || this.formInfo.departmentLeaderList == '') {
        modal.warn({title: '温馨提示', content: '科室领导不能为空'})
        return
      }
      if(disposalPsAllotVOS.length === 0){
        modal.warn({title: '温馨提示', content: '无可保存数据!'})
        return
      }
      this.$loading.show('正在处理数据,请等待...')
      const params = {}
      params.disposalPsAllotVOS = disposalPsAllotVOS
      params.disposalManList = []
      //处置人员，责任领导，科室领导由多选改为单选
      params.disposalManList.push(this.formInfo.disposalManList)
      params.dutyLeaderList = []
      params.dutyLeaderList.push(this.formInfo.dutyLeaderList)
      params.departmentLeaderList = []
      params.departmentLeaderList.push(this.formInfo.departmentLeaderList)
      setTimeout(() => {
        this.$http.post(disposalAllotTaskBatch, params).then((res) => {
          this.$loading.hide()
          this.$message.info('保存成功')
          this.$emit("handleCancel")
          if(this.listQuery){
            this.listQuery()
          }
        }).catch((error) => {
          this.$loading.hide()
          console.log(JSON.stringify(error))
        }).finally(() =>{
        })
      }, 50)
    },
  }
}
</script>

<style scoped>

</style>